home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / gnudev1.zip / emx / doc / duel.man < prev    next >
Text File  |  1993-03-19  |  28KB  |  502 lines

  1.  
  2.  
  3.  
  4.      DDDDuuuueeeellll((((1111))))                 VVVVeeeerrrrssssiiiioooonnnn 1111....11110000 ((((MMMMaaaarrrr 99993333))))                  DDDDuuuueeeellll((((1111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.      duel - A high level C debugging language extension to gdb
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      dddduuuueeeellll [gdb options] [_p_r_o_g[_c_o_r_e|_p_r_o_c_I_D]]
  13.  
  14.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  15.      Duel  is  a  special  purpose  language  designed  for  concise  state
  16.      exploration  of  debugged  C programs, currently implemented under the
  17.      GNU debugger _g_d_b(1).  Duel is invoked by entering  the  shell  command
  18.      _d_u_e_l instead of _g_d_b. It is identical to gdb except for comments, which
  19.      begin with `##' instead of `#',  and  the  new  _d_l  command  for  Duel
  20.      expressions:
  21.  
  22.      _g_d_b> dl x[1..10] >? 5
  23.      x[3] = 14
  24.      x[8] = 6
  25.  
  26.      prints the array elements x[1] to x[10] that are greater than  5.  The
  27.      output  includes  the  values  14  and  6,  as  well as their symbolic
  28.      representation "x[3]" and "x[8]".
  29.  
  30.      IIIIFFFF YYYYOOOOUUUU NNNNEEEEVVVVEEEERRRR UUUUSSSSEEEEDDDD GGGGDDDDBBBB
  31.      The improved functionality added by Duel merits a fresh look  even  by
  32.      debugger  shunners.   Gdb is a powerful debugger with many commands, a
  33.      thick manual and various interfaces including _e_m_a_c_s(1)  and  _x_x_g_d_b(1).
  34.      These gdb commands should help you get started:
  35.  
  36.      _b _l_i_n_e   set a breakpoint at the line (b func to break at a function)
  37.      _d _n      delete breakpoint number n (gdb prints n when bp occurs)
  38.      _l _l_i_n_e   list the source beginning at line (l file.c:line for module)
  39.      _r _p_a_r_m   run/restart the program with the given parameters
  40.      _s        single-step to the next statement (steps into function calls)
  41.      _n        single-step to the next line, skipping over function calls
  42.      _c        continue execution
  43.      _b_t       show a stack trace
  44.      _p _e_x_p    evaluate a symbolic expression
  45.      _d_l _e_x_p   evaluate a Duel expression
  46.      _d_l _g_d_b   give a gdb command summary
  47.  
  48.      The most common use is `b func' followed by `r'  followed  by  several
  49.      `n' and `s', evaluating expressions in between.
  50.  
  51.      DDDDUUUUEEEELLLL QQQQUUUUIIIICCCCKKKK SSSSTTTTAAAARRRRTTTT
  52.      Duel is implemented by adding the _d_l command to gdb. All gdb  commands
  53.      work  as before. The dl command, however, is interpreted by duel.  Gdb
  54.      concepts (such as the value history) do not work in  the  dl  command,
  55.      and duel concepts are not understood by other gdb command.
  56.  
  57.      Duel is based on expressions which return multiple values.   The  x..y
  58.      operator  returns the integers from x to y; the x,y operator returns x
  59.      and then y, e.g.
  60.  
  61.      _g_d_b> dl (1,9,12..15,22)
  62.  
  63.      prints 1, 9, 12, 13, 14, 15 and  22.  Such  expressions  can  be  used
  64.      wherever a single value is used, e.g.
  65.  
  66.      _g_d_b> dl x[0..99]=0 ;
  67.  
  68.      assigns zero to the first 100 elements of array x.  The  semantics  of
  69.      x[i]  are  the  same  as in C. They are applied for each of the values
  70.      returned by 0..99, which can be thought  of  as  an  implied  external
  71.      loop.   The  trailing  semicolon indicates evaluation for side-effects
  72.      only,  with  no  output.  Duel  incorporates  C  operators,  casts   C
  73.      statements as expressions, and supports limited  variable declaration:
  74.  
  75.      _g_d_b> dl int i;for(i=0;i<100;i++)
  76.                       if(x[i]<0) printf("x[%d]=%d\n",i,x[i]);
  77.      x[7] = -4
  78.  
  79.      The semicolon  prevents  Duel  output;  only  output  from  printf  is
  80.      printed.   Aliases are defined with x:=y and provide an alternative to
  81.      variable declaration. We could  also  return  x[i]  instead  of  using
  82.      printf:
  83.  
  84.      _g_d_b> dl if(x[i:=0..99]<0) x[i]
  85.      x[i] = -4
  86.  
  87.      The symbolic output "x[i]" can be fixed by surrounding i with {}, i.e.
  88.  
  89.      _g_d_b> dl if(x[i:=0..99]<0) x[{i}]
  90.      x[7] = -4
  91.  
  92.      The {} are like (), but force  the  symbolic  evaluation  to  use  i's
  93.      value,  instead  of  "i".  You  can usually avoid this altogether with
  94.      direct Duel operators:
  95.  
  96.      _g_d_b> dl x[..100] <? 0
  97.      x[7] = -4
  98.  
  99.      The ..n operator is a shorthand for 0..n-1, i.e. ..100 is the same  as
  100.      0..99.   The  x<?y,  x==?y,  x>=?y, etc., operators compare their left
  101.      side operand to their right side operand as in C, but return the  left
  102.      side  value if the comparison result is true. Otherwise, they look for
  103.      the next values to compare, without returning anything.
  104.  
  105.      Duel's x.y and x->y allow an expression y, evaluated under x's scope:
  106.  
  107.      _g_d_b> dl emp[..100].(if(code>400) (code,name))
  108.      emp[46].code = 682
  109.      emp[46].name = "Ela"
  110.  
  111.      The if() expression is evaluated under the scope of  each  element  of
  112.      emp[], an array of structures. In C terms, we had to write:
  113.  
  114.      _g_d_b> dl int i; for(i=0; i<100 ; i++)
  115.            if(emp[i].code>400) emp[{i}].code,emp[{i}].name
  116.  
  117.      A useful alternative to loops is the x=>y operator. It returns  y  for
  118.      each value of x, setting `_' to reference x's value, e.g.
  119.  
  120.      _g_d_b> ..100 => if(emp[_].code>400) emp[_].code,emp[_].name
  121.  
  122.      Using `_' instead of `i' also avoids the need for  {i}.  Finally,  the
  123.      x-->y operator expands lists and other data structures. If head points
  124.      to a linked list threaded through the next field, then:
  125.  
  126.      _g_d_b> dl head-->next->data
  127.      head->data = 12
  128.      head->next->data = 14
  129.      head-->next[[2]]->data = 20
  130.      head-->next[[3]]->data = 26
  131.  
  132.      produce the data field for each node in the list. x-->y returns x,  x-
  133.      >y,  x->y->y,  x->y->y->y,  ...  until  a  NULL is found. The symbolic
  134.      output "x-->y[[n]]" indicates that ->y was applied n times. x[[y]]  is
  135.      also the selection operator:
  136.  
  137.      _g_d_b> dl head-->next[[50..60]]->data
  138.  
  139.      return the 50th through  the  60th  elements  in  the  list.  The  #/x
  140.      operator counts the number of values, so
  141.  
  142.      _g_d_b> dl #/( head-->next->data >? 50 )
  143.  
  144.      counts the number of data elements over 50 on the list.  Several other
  145.      operators,  including  x@y,  x#y  and  active  call  stack  access are
  146.      described in the operators section.
  147.  
  148.      OOOOPPPPEEEERRRRAAAATTTTOOOORRRRSSSS SSSSUUUUMMMMMMMMAAAARRRRYYYY
  149.      Assoc   Operators                   Details
  150.      left    {} () [] -> . f() -->       x-->y expands x->y x->y->y ...
  151.              x[[y]] x#y x@y              generate x; select, index or stop-at y
  152.      right   #/ - * & ! ~ ++ -- (cast)   #/x number of x values
  153.              frame(n) sizeof(x)          reference to call stack level n
  154.      left    x/y x*y x%y                 multiply, divide, reminder
  155.      left    x-y x+y                     add, subtract
  156.      left    x<<y x>>y                   shift left/right
  157.      none    x..y ..y x..                ..y = 0..y-1. x..y return x, x+1...y
  158.      left    < > <= >= <? >? <=? >=?     x>?y return x if x>y
  159.      left    == != ==? !=?               x==?y return x if x==y
  160.      left    x&y                         bit-and
  161.      left    x^y                         bit-xor
  162.      left    x|y                         bit-or
  163.      left    x&&y &&/x                   &&/x are all x values non-zero?
  164.      left    x||y ||/x                   ||/x is any x value non-zero?
  165.      right   x? y:z                      foreach x, if(x) y else z
  166.      right   x:=y x=y x+=y ...           x:=y set x as an alias to y
  167.      left    x,y                         return x, then y
  168.      right   x=>y                        foreach x, evaluate y with x value `_'